import torch
import sys

print(f"Python版本: {sys.version}")
print(f"PyTorch版本: {torch.__version__ if hasattr(torch, '__version__') else '未安装'}")
print(f"CUDA版本: {torch.version.cuda if hasattr(torch, 'version') and hasattr(torch.version, 'cuda') else '未安装'}")
print(f"CUDA可用: {torch.cuda.is_available() if hasattr(torch, 'cuda') else '无法检测'}")

if hasattr(torch, 'cuda') and torch.cuda.is_available():
    print(f"GPU数量: {torch.cuda.device_count()}")
    print(f"GPU名称: {torch.cuda.get_device_name(0)}")
    print(f"CUDA设备路径: {torch.cuda.current_device()}")
    print(f"CUDA安装路径: {torch.utils.cpp_extension.CUDA_HOME if hasattr(torch.utils, 'cpp_extension') and hasattr(torch.utils.cpp_extension, 'CUDA_HOME') else '无法检测'}")

# 尝试导入cv2
print("\n尝试导入OpenCV...")
try:
    import cv2
    print(f"OpenCV版本: {cv2.__version__}")
except ImportError:
    print("OpenCV未安装")